#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: node08_fileld_rename.py 
@version:
@time: 2022/05/18 
"""
# 01
from TapClientCore.T04_logic.Dag02.node.node_base import NodeBase


class FieldRenameNode(NodeBase):
    """
    {"id":"6283cd914f15a8260b44ebef",
    "op":"RENAME",
    "field":"column_1",
    "operand":"new_name1",
    "table_name":"AA",
    "type":"Long",
    "primary_key_position":0,
    "label":"new_name1",
    "field_name":"new_name1",
    "reset":false}
    
    "fieldsNameTransform": "toUpperCase"
    "fieldsNameTransform": "toLowerCase"
    """
    node = None

    def __init__(self, operations=None):
        if operations is None:
            operations = []
        self.generate_node(operations)

    def generate_node(self, operations):
        _operations = operations.get('operations')
        if not _operations:
            _operations = []
        node = {
            "id": self.newId,
            "name": "自动化-字段改名",
            "type": "field_rename_processor",
            "attrs": {
                "position": [
                    -600,
                    0
                ]
            },
            "operations": _operations,

        }
        fieldsNameTransform = operations.get('fieldsNameTransform')
        if fieldsNameTransform:
            node.update({
                'fieldsNameTransform': fieldsNameTransform
            })
        self.node = node
